<!-- 台区 -->
<template>
  <div>
    <el-dialog :title="this.showtitle" v-bind="dialogProps" :before-close="handleClose" :close-on-click-modal="false"
               :destroy-on-close="true" v-dialogDrag append-to-body>
      <div style="display: flex;flex-direction: column;align-items: end;;">
        <!-- <el-button type="primary" size="small" @click="exportFile()">导出excel</el-button> -->
      </div>

      <vxe-table border stripe ref="table1" height="400" :data="list1.data">
        <vxe-column type="seq" title="序号" width="60" align="center"></vxe-column>
        <vxe-column field="stockNum" title="库存" align="center" minWidth="150"></vxe-column>
        <vxe-column field="stockNum" title="盘点" align="center" minWidth="150"></vxe-column>
        <vxe-column field="stockMethodName" title="盘点方式" align="center" minWidth="150"></vxe-column>
        <vxe-column field="factoryNo" title="出厂编码" align="center" minWidth="200"></vxe-column>
        <vxe-column field="equipName" title="设备名称" align="center" minWidth="150"></vxe-column>
        <vxe-column field="equipTypeName" title="设备类型" align="center" minWidth="150"></vxe-column>
        <vxe-column field="meterTypeName" title="计量方式" align="center" minWidth="150"></vxe-column>
        <vxe-column field="equipSpecification" title="规格" align="center" minWidth="150"></vxe-column>
        <vxe-column field="model" title="型号" align="center" minWidth="150"></vxe-column>
        <vxe-column field="pt" title="PT" align="center" minWidth="150"></vxe-column>
        <vxe-column field="ct" title="CT" align="center" minWidth="150"></vxe-column>
        <vxe-column field="factoryName" title="厂家" align="center" minWidth="150"></vxe-column>
      </vxe-table>
      <vxe-pager perfect size="mini" :current-page="list1.pageNo" :page-size="list1.pageSize"
                 :page-sizes="list1.pageSizes" :total="list1.total"
                 :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']"
                 @page-change="handlePageChange1">
      </vxe-pager>
    </el-dialog>
  </div>
</template>
<script>
import {godownEntryApi} from "@/api/equip/godownEntryApi";

export default {
  components: {},
  data() {
    return {
      showtitle: "盘点总数明细",
      selectRow: null,
      selectRow1: null,
      size: "medium",
      ruleForm: {
        sbmc: '',
        sbbm: '',
        yxzt: ''
      },
      dialogProps: {
        visible: false,

        width: "80%",
        top: "10px",
      },
      djztOptions: [],
      overheadLine: false,

      list1: {
        data: [],
        pageNo: 1,
        pageSize: 10,
        pageSizes: [10, 20, 50, 100],
        total: 0
      },
      loading: false,
      row: {}
    };
  },
  mounted() {
    this.$nextTick(() => {

    })

  },
  methods: {
    showDialog(isEdit, row, isDisabled, title) {
      this.showtitle = title
      this.dialogProps.visible = true
      console.log(row)
      this.row = row
      this.getTable()


    },
    exportFile() {

    },
    getTable() {
      const pageParams = {
        pageSize: this.list1.pageSize,
        pageNo: this.list1.pageNo,
        entity: {
          taskNo: this.row.taskNo,
        },
        paramsMap: {},
        column: '',
        order: ''
      }
      if (this.showtitle == '匹配数量明细') {
        pageParams.entity.equipTypeNo = this.row.equipTypeNo
        godownEntryApi.getTaskEquipMatchList(pageParams).then(res => {
          this.list1 = {
            pageNo: res.data.current,
            pageSize: res.data.size,
            pageSizes: [10, 20, 50, 100],
            total: res.data.total
          }
          let arr = []
          res.data.records.forEach((item) => {
            arr.push({
              stockNum: item.stockNum,
              pd: item.pd,
              stockMethodName: item.stockMethodName,
              factoryNo: item.ccbm,
              equipName: item.sbmc,
              equipTypeName: item.sblxmc,
              meterTypeName: item.jlfsmc,
              equipSpecification: item.sbgg,
              model: item.xh,
              pt: item.pt,
              ct: item.ct,
              factoryName: item.cjmc,
              detailedDescription: item.detailedDescription
            })
            this.list1.data = arr
            console.log(this.list1.data)

          })
        })
      } else if (this.showtitle == '差异明细') {
        pageParams.entity = this.row
        godownEntryApi.getTaskEquipDiffList(pageParams.entity).then(res => {
          this.list1 = {
            pageNo: res.data.current,
            pageSize: res.data.size,
            pageSizes: [10, 20, 50, 100],
            total: res.data.total
          }
          let arr = []
          res.data.forEach((item) => {
            arr.push({
              stockNum: item.stockNum,
              pd: item.pd,
              stockMethodName: item.stockMethodName,
              factoryNo: item.ccbm,
              equipName: item.sbmc,
              equipTypeName: item.sblxmc,
              meterTypeName: item.jlfsmc,
              equipSpecification: item.sbgg,
              model: item.xh,
              pt: item.pt,
              ct: item.ct,
              factoryName: item.cjmc,
              detailedDescription: item.detailedDescription
            })
            this.list1.data = arr
          })
        })
      } else if (this.showtitle == '盘点总数明细') {
        pageParams.entity = this.row
        godownEntryApi.getTaskEquipList(pageParams).then(res => {
          this.list1 = {
            data: res.data.records,
            pageNo: res.data.current,
            pageSize: res.data.size,
            pageSizes: [10, 20, 50, 100],
            total: res.data.total
          }
        })
      } else {
        pageParams.entity = this.row
        pageParams.entity.sblxbm = this.row.equipTypeNo
        pageParams.entity.sblxmc = this.row.equipTypeName
        pageParams.entity.sskfbm = this.row.warehouseNo
        godownEntryApi.getTaskpage(pageParams).then(res => {
          this.list1 = {
            pageNo: res.data.current,
            pageSize: res.data.size,
            pageSizes: [10, 20, 50, 100],
            total: res.data.total
          }
          let arr = []
          res.data.records.forEach((item) => {
            arr.push({
              stockNum: item.stockNum,
              pd: item.pd,
              stockMethodName: item.stockMethodName,
              factoryNo: item.ccbm,
              equipName: item.sbmc,
              equipTypeName: item.sblxmc,
              meterTypeName: item.jlfsmc,
              equipSpecification: item.sbgg,
              model: item.xh,
              pt: item.pt,
              ct: item.ct,
              factoryName: item.cjmc,
              detailedDescription: item.detailedDescription
            })
            this.list1.data = arr

          })
        })
      }
      this.setReadModel()
    },
    setReadModel() { //控制显示隐藏
      let columns2 = this.$refs.table1
      setTimeout(() => {
        if (this.showtitle == '库存数量明细') {

          this.$refs.table1.hideColumn(this.$refs.table1.getColumnByField('stockMethodName'))
        }
        if (this.showtitle != '差异明细') {
          this.$refs.table1.hideColumn(this.$refs.table1.getColumnByField('stockNum'))
          this.$refs.table1.hideColumn(this.$refs.table1.getColumnByField('pd'))
        }
      }, 100)
    },
    //分页查询
    handlePageChange1({currentPage, pageSize}) {
      this.loading = true
      this.list1.pageNo = currentPage;
      this.list1.pageSize = pageSize;
      this.getTable()
    },
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          // this.handleCancel()
          this.dialogProps.visible = false;
          this.list1.pageNo = 1
          this.list1.pageSize = 10
          this.list1.data = []
        })
        .catch((_) => {
        });
    },
  },
};
</script>
<style>
.el-dialog__footer {
  width: 100%;
  border-top: 1px solid #e8e8e8;
}
</style>
